/*
 * @Author: byron
 * @Date: 2022-01-30 16:20:49
 * @LastEditTime: 2022-05-09 17:16:11
 */
import {
    Skeleton,
    Input,
    Dialog,
    Button,
    Carousel,
    CarouselItem,
    Table,
    TableColumn,
    Link,
    Popover,
    Progress,
    Breadcrumb,
    BreadcrumbItem,
    Pagination,
    Card,
    Switch,
    Timeline,
    TimelineItem,
    SkeletonItem,
} from 'element-ui'
import VueLazyload from 'vue-lazyload'
import directive from '@/directives/index'
import messageBox from '@/components/message/index'
import Loading from '@/components/loading/index'

import '@/style/index.less'
import '@/style/overwrite-ele.less'

//   import Meta from 'vue-meta'
//   import * as utils from "./index"
//   import { EMPTY_IMG } from "./dom"

export default {
    install(Vue) {
        // 使用require.context()实现前端工程化引入文件
        const requireComponent = require.context(
            '@/base',
            true, // 代表是否检索子文件夹
            /[a-z0-9]+\.(vue)$/i //检索文件的正则表达式
        )
        // 批量注册base组件
        requireComponent.keys().forEach((fileName) => {
            const componentConfig = requireComponent(fileName)
            const componentName = componentConfig.default.name
            if (componentName) {
                Vue.component(
                    componentName,
                    componentConfig.default || componentConfig
                )
            }
        })

        Vue.use(Input)
        Vue.use(Carousel)
        Vue.use(CarouselItem)
        Vue.use(Table)
        Vue.use(TableColumn)
        Vue.use(Popover)
        Vue.use(Progress)
        Vue.use(Switch)
        Vue.use(Pagination)
        Vue.use(Skeleton)
        Vue.use(Dialog)
        Vue.use(Button)
        Vue.use(Card)
        Vue.use(Link)
        Vue.use(Timeline)
        Vue.use(Breadcrumb)
        Vue.use(TimelineItem)
        Vue.use(SkeletonItem)
        Vue.use(BreadcrumbItem)

        Vue.use(messageBox)
        Vue.use(Loading)

        //   Vue.use(Meta)

        //图片懒加载
        Vue.use(VueLazyload)

        Vue.use(VueLazyload, {
            preLoad: 1.3,
            error: '@/static/picture/微信图片_20210722115258.png',
            loading: 'https://ui.vtuzx.com/static/img/wait.02a5df3.gif',
            attempt: 1,
        })

        Vue.use(directive)
    },
}
